local hx__jijing = fk.CreateSkill {
  name = "hx__jijing",
}

hx__jijing:addEffect(fk.TurnEnd, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(hx__jijing.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local y = player:getMark("@hx__qinggang")
    local x = math.min(player.maxHp, y)
    local choices = {}
    for i = 0, x do
      table.insert(choices, tostring(i))
    end
    if y == 0 then
      room:changeHp(player, -player.hp, nil, hx__jijing.name)
    else
      local choice = room:askToChoice(player, {
        choices = choices,
        skill_name = hx__jijing.name,
        prompt = "请选择调整体力值为？",
      })
      if choice ~= tostring(player.hp) then
        local hp = tonumber(choice)
        room:setPlayerProperty(player, "hp", hp)
        room:broadcastProperty(player, "hp")
      end
    end
  end,
})

return hx__jijing